﻿@using cloudscribe.Web.Pagination
@using conan.Saas
@using conan.Saas.Controllers
@using dotNET.Domain.Entities
@using  dotNET.Dto
@using conan.Saas.Model
@model BaseListViewModel<Role>
@{
    Layout = "_Layoutlist";
    RoleOption filer = ViewBag.filter as RoleOption;

}

@section headers{

}

<!-- Main content -->
<section class="content">

    <div class="row">
        <!-- BEGIN SAMPLE TABLE PORTLET-->
        <div class="col-md-12">
            <!-- BEGIN SAMPLE TABLE PORTLET-->
            <div class="box-body" style="padding-bottom:0px;">
                <!--<div class="panel panel-default">-->

                <div class="search row">
                    <div class="col-sm-12 form-group">
                        <div class="form-inline">
                            <form action="/Role/index" method="get" id="searchform">

                             

                                <div class="form-group ">
                                    <label class="control-label  label-lg label-md">名称:</label>
                                    @Html.TextBox("Name", @filer.Name, new { placeholder = "名称", @class = "form-control input-small input-sm" })
                                </div>
                                <span class="form-group btn-group">
                                    <button class="btn btn-sm btn-info" type="submit"><i class="fa fa-search"></i> 搜索</button>
                                </span>
                            </form>
                        </div>
                    </div>
                </div>
                <!--</div>-->
                <div style="  position: relative;
            margin-top: 10px;
            margin-bottom: 10px;
            line-height: 34px;">
                    <div id="toolbar" class="btn-group">


                        <button id="btn_add" type="button" class="btn btn-default">

                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
                        </button>

                   
                    </div>

                </div>


                <div class="table-scrollable">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr class="heading">
                                <th>Id</th>
                              
                                <th>名称</th>
                                <th>描述</th>
                              
                                <th>创建时间</th>
                              

                                <th style="width:120px">操作</th>
                            </tr>
                        </thead>
                        <tbody id="tbody">

                            @if (Model.list.Count > 0)
                            {
                                @foreach (var s in Model.list)
                                {
                                    <tr>
                                        <td>@s.Id</td>
                                        <td>@s.Name</td>
                                        <td>@s.Description</td>
                                      
                                        <td>@(s.CreatorTime.ToString("yyyy/MM/dd HH:mm:ss") ) </td>
                                      

                                        <td>
                                            <a href="javascript:void(0);" onclick="btndelete('@s.Id');" class="aDel">删除</a>

                                           
                                          


                                            <a href="/role/Edit?Id=@s.Id">编辑</a>
                                        </td>
                                    </tr>
                                }
                            }
                        </tbody>
                    </table>
                </div>
                @if (Model.list.Count > 0)
                {
                    <div class="fixed-table-pagination" style="display: block;">
                          <div class="col-sm-4 hidden-xs" style="padding-top:4px;">

                            <span class="pagination-info"> 显示 第 @( (Model.Paging.ItemsPerPage * (Model.Paging.CurrentPage - 1)) + 1) 到 @( (Model.Paging.ItemsPerPage * Model.Paging.CurrentPage) > Model.Paging.TotalItems ? Model.Paging.TotalItems : (Model.Paging.ItemsPerPage * Model.Paging.CurrentPage) ) 条， 共 @Model.Paging.TotalItems 条</span>
                        </div>
                        <div class="col-sm-8 dataTables_paginate;" style="  padding-right:15px; margin-right:0px;">

                        
                            <cs-pager cs-paging-pagesize="@Model.Paging.ItemsPerPage"
                                      cs-paging-pagenumber="@Model.Paging.CurrentPage"
                                      cs-paging-totalitems="@Model.Paging.TotalItems"
                                      cs-pagenumber-param="page"
                                      asp-controller="role"
                                      asp-action="index"
                                      asp-route-Name="@filer.Name"
                                    
                                      @*asp-route-categoryname="@filer.categoryName"
                                      asp-route-pp="@filer.pp" *@
                                      asp-route-pagesize="@Model.Paging.ItemsPerPage"></cs-pager>
                        </div>
                    
                    </div>
                }
            </div>
            <!-- END SAMPLE TABLE PORTLET-->

           </div>


    </div>

</section>



@section scripts{

    <script>

        $("#btn_add").click(function () {
            location.href = "/role/Create";
        });
    </script>


    <script>

        //删除
        function btndelete(id) {

            layer.confirm("确定删除", { title: "删除" }, function (index) {

                $.ajax({
                    url: "/role/Delete?id=" + id,
                    type: "POST",
                    cache: false,
                    success: function (r) {
                        if (r.isSucceeded == true) {
                            location.href = location.href;
                        }
                        else  // 其他问题
                        {
                            $.MsgBox.Alert(r.message);
                        }
                    },
                    error: function () {

                        $.MsgBox.Alert("操作失败", "提示");
                    }
                });

                layer.close(index);
            });
        }


    





      
    </script>
}

